home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / LISP Related / MCL Utilities / Sound Manager / play-snd.lisp < prev    next >
Encoding:
Text File  |  1990-09-04  |  1.3 KB  |  41 lines  |  [TEXT/CCL ]

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;; Copyright 1987, 1988, 1989, 1990 by Ruben Kleiman for Apple Computer, Inc.
  3. ;;; Advanced Technology Group
  4. ;;;
  5.  
  6. (require :traps)
  7.  
  8. (provide :play-snd)
  9.  
  10. (in-package 'sound)
  11.  
  12. (export '(play-snd))
  13.  
  14. (defun play-snd (soundName &key (synthType sampledSynth) resFileName
  15.                            &aux resFileRefNum resHandle)
  16.   "Plays an snd resource on a selected synthetizer channel"
  17.   (%stack-block ((channel 4))
  18.     (%put-long channel 0 0)    
  19.     
  20.     ;; Load any resource file
  21.     (when resFileName
  22.       (with-pstrs ((PascalFileName resFileName))
  23.         (if resFileName
  24.           (if (= -1 (setq resFileRefNum (_openResFile :ptr PascalFileName :word)))
  25.             (error "Resource file ~a could not be opened." resFileName)))))
  26.     
  27.     ;; Load the snd resource
  28.     (with-pstrs ((PascalResName soundName))
  29.       (setq resHandle (_getNamedResource :word #x6420 :word #x736e :ptr PascalResName :ptr))
  30.       (_detachresource :ptr resHandle))
  31.     
  32.     (_SndNewChannel :ptr channel :word synthType :long 'y :ptr nil :word)
  33.     
  34.     (_SndPlay :ptr (%get-ptr channel 0) :ptr resHandle :word -1 :word)
  35.     
  36.     (_SndDisposeChannel :ptr (%get-ptr channel 0) :word 0))
  37.   
  38.   (if resFileRefNum
  39.     (_closeResFile :word resFileRefNum)))
  40.  
  41.